import React, {Component} from 'react';
// 引入querystring库将query参数字符串转成对象
// import qs from 'querystring'
const detailData = [
    {id:"01",content:'学习Vue'},
    {id:"02",content:'学习React'},
    {id:"03",content: '学习Angular'}
]
export default  class Detail extends Component {
    render() {
        console.log('props',this.props)
        // 后面必须加上空对象,不然state会返回undefined
        const {id,title} = this.props.location.state || {}

        const findResult = detailData.find(detailObj=>{
            return detailObj.id === id
        }) || {}

        return (
            <ul>
                <li>ID:{id}</li>
                <li>TiTLE:{title}</li>
                <li>CONTENT:{findResult.content}</li>

            </ul>
        );
    }
}


